﻿<?php

class FilterWord{

// 	public static function filter_sensitive_word(){
// 		foreach($_POST as $k=>$v){
// 			$_POST[$k] = $this->replace_sensitive_word($v);
// 		}
// 	}
	
	//全局过滤敏感词
	public static function filter_sensitive_word($post){
		
		foreach($post as $k=>$v){
			$post[$k] = FilterWord::replace_sensitive_word($v);
		}
		return $post;
	}
	
//	替换指定的敏感词
	public static function  replace_sensitive_word($word){
	
		$arr = file("./sensitive_word.txt");//敏感词典
		$arr1 = array();
		foreach($arr as $k=>$v){
			$arr1["num".$k] = trim($v);
		}
		return  $content = str_replace($arr1,"*",$word);
	}

}